package com.ruoyi.job.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.business.waterManagement.StStationR;
import com.ruoyi.common.core.domain.business.waterManagement.WrStationR;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.job.mapper.StStationRMapper;
import com.ruoyi.job.mapper.WrStationRMapper;
import com.ruoyi.job.service.IStStationRService;
import com.ruoyi.job.service.IWrStationRService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * 水量在线监测站数据记录Service业务层处理
 *
 * @author hwd
 * @date 2023-02-20
 */
@Service
public class WrStationRServiceImpl extends ServiceImpl<WrStationRMapper, WrStationR> implements IWrStationRService
{
    @Autowired
    private WrStationRMapper wrStationRMapper;

    /**
     * 查询水量在线监测站数据记录
     *
     * @param statCd 水量在线监测站数据记录主键
     * @return 水量在线监测站数据记录
     */
    @Override
    public WrStationR selectWrStationRByStatCd(String statCd)
    {

        return wrStationRMapper.selectWrStationRByStatCd(statCd);
    }

    /**
     * 查询水量在线监测站数据记录列表
     *
     * @param wrStationR 水量在线监测站数据记录
     * @return 水量在线监测站数据记录
     */
    @Override
    public List<WrStationR> selectWrStationRList(WrStationR wrStationR)
    {
        if (wrStationR.getChkTime()!=null){
            String [] strings= DateUtils.jsYmd(wrStationR.getChkTime());
            String yy =strings[0];
            String mm =strings[1];
            String dd =strings[2];
            wrStationR.setYy(yy);
            wrStationR.setMm(mm);
            wrStationR.setDd(dd);
        }
        return wrStationRMapper.selectWrStationRList(wrStationR);
    }

    /**
     * 新增水量在线监测站数据记录
     *
     * @param wrStationR 水量在线监测站数据记录
     * @return 结果
     */
    @Override
    public int insertWrStationR(WrStationR wrStationR)
    {
        return wrStationRMapper.insertWrStationR(wrStationR);
    }

    /**
     * 修改水量在线监测站数据记录
     *
     * @param wrStationR 水量在线监测站数据记录
     * @return 结果
     */
    @Override
    public int updateWrStationR(WrStationR wrStationR)
    {
        return wrStationRMapper.updateWrStationR(wrStationR);
    }

    /**
     * 批量删除水量在线监测站数据记录
     *
     * @param statCds 需要删除的水量在线监测站数据记录主键
     * @return 结果
     */
    @Override
    public int deleteWrStationRByStatCds(String[] statCds)
    {
        return wrStationRMapper.deleteWrStationRByStatCds(statCds);
    }

    /**
     * 删除水量在线监测站数据记录信息
     *
     * @param statCd 水量在线监测站数据记录主键
     * @return 结果
     */
    @Override
    public int deleteWrStationRByStatCd(String statCd)
    {
        return wrStationRMapper.deleteWrStationRByStatCd(statCd);
    }
    @Override
    public List<WrStationR> selWrStationRHourAvgCurFlow(String statCd, Date chktime, Date zeroDate) {
        return wrStationRMapper.selWrStationRHourAvgCurFlow(statCd,chktime,zeroDate);
    }

    @Override
    public WrStationR selWrStationRHourVol(String statCd, Date chktime, Date lastChkTime) {
        return wrStationRMapper.selWrStationRHourVol(statCd,chktime,lastChkTime);
    }
}
